import { create } from 'zustand';

interface AuthState {
  isAuthenticated: boolean;
  username: string | null;
  setAuth: (username: string) => void;
  clearAuth: () => void;
}

const useAuthStore = create<AuthState>((set) => ({
  isAuthenticated: !!localStorage.getItem('token'),
  username: localStorage.getItem('username'),
  setAuth: (username: string) => {
    console.log('Setting auth:', { username });
    set({ isAuthenticated: true, username });
  },
  clearAuth: () => {
    console.log('Clearing auth');
    set({ isAuthenticated: false, username: null });
  }
}));

export default useAuthStore; 